package com.itheima.tezheng;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

public class Demo02 {

    public static void main(String[] args) {
        SongBinggun songBinggun = new SongBinggun();
        for (int i = 0; i < 100; i++) {
            Thread t1 = new Thread(songBinggun);
            t1.start();
        }


    }
}


class SongBinggun implements Runnable {
     AtomicInteger count = new AtomicInteger();//999988
    ReentrantLock lock = new ReentrantLock();

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            // synchronized (lock) {
            //lock.lock();
            System.out.println("送了" + count.incrementAndGet() + "个冰棍");
           // lock.unlock();
            // }
        }
    }
}